<template>
  <div class="board-column">
    <div class="board-column-header">
      {{ headerText }}
    </div>
    <draggable
      :list="list"
      :options="options"
      draggable=".board-item"
      class="board-column-content">
      <div v-for="element in list" :key="element.id" class="board-item">
        {{ element.name }} {{ element.id }}
      </div>
      <el-button :class="{unShow: allowAdd}" class="button-item" @click="addItem()">
        <i class="el-icon-plus button-item__plus"/>
      </el-button>
    </draggable>

    <el-dialog :visible.sync="dialogVisible" width="35%" title="填写">
      <el-form>
        <el-form-item :label-width="formLabelWidth" label="任务概述">
          <el-input v-model="mission" placeholder="请输入内容" prefix-icon="el-icon-edit-outline" autocomplete="off"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import draggable from 'vuedraggable'

export default {
  name: 'DragKanbanDemo',
  components: {
    draggable
  },
  props: {
    headerText: {
      type: String,
      default: 'Header'
    },
    options: {
      type: Object,
      default() {
        return {}
      }
    },
    allowAdd: {
      type: Boolean,
      default() {
        return false
      }
    },
    list: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      dialogVisible: false,
      formLabelWidth: '120px',
      mission: ''
    }
  },
  methods: {
    addItem() {
      this.dialogVisible = true
    }
  }
}
</script>
<style lang="scss">
.board-column {
  min-width: 300px;
  min-height: 100px;
  height: auto;
  overflow: hidden;
  background: #f0f0f0;
  border-radius: 3px;

  .board-column-header {
    height: 50px;
    line-height: 50px;
    overflow: hidden;
    padding: 0 20px;
    text-align: center;
    background: #333;
    color: #fff;
    border-radius: 3px 3px 0 0;
  }

  .board-column-content {
    height: auto;
    overflow: hidden;
    border: 10px solid transparent;
    min-height: 60px;
    display: flex;
    justify-content: flex-start;
    flex-direction: column;
    align-items: center;

    .board-item,.button-item {
      cursor: pointer;
      width: 100%;
      height: 64px;
      margin: 5px 0;
      background-color: #fff;
      text-align: left;
      line-height: 54px;
      padding: 5px 10px;
      box-sizing: border-box;
      box-shadow: 0px 1px 3px 0 rgba(0,0,0,0.2);
    }
    .button-item {
      height: 44px;
      position: relative;
      &__plus {
        position: absolute;
        top:calc(50% - 13px);
        left: calc(50% - 13px);
        font-size: 26px;
      }
    }
    .unShow {
      display: none;
    }
  }
}
</style>

